# Build recipe for qi.
#
# Copyright (c) 2017-2018 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=qi
version=1.0-rc52
arch=noarch
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/tools"

tarname=${program}-${version}.tar.lz

# Remote source(s)
fetch="
 http://rsync.dragora.org/current/sources/$tarname
 http://gungre.ch/dragora/mirror/current/sources/$tarname
"

description="
A practical and user-friendly package manager.

Qi provides operating modes for build, install, remove, upgrade,
and inspect software packages.

Qi produces software packages using recipe names (also known as
"ports"); in this case, simple text files that contain shell
instructions.

Qi has been written to make use of Graft, a symlink utility to
keep your packages under a single directory hierarchy, it was inspired
by both Depot (Carnegie Mellon University) and Stow (Bob Glickstein).
"

homepage=http://www.dragora.org
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING CREDITS NEWS README doc/example.order"
docsdir="${docdir}/${program}"

# Limit package name to the program name
full_pkgname=$program

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    ./configure $configure_args --packagedir=/usr/pkg --targetdir=/

    make -j${jobs} DESTDIR="$destdir" install

    # Copy the config file used in the temporary system
    if test -r /tools/etc/qirc
    then
        cp -p /tools/etc/qirc "${destdir}/etc/"
        chmod 644 "${destdir}/etc/qirc"
    fi

    # Manage dot new file(s)
    touch "${destdir}/etc/.graft-config"

    # Compress and copy source documents

    lzip -9 "${destdir}/${infodir}/qi.info" \
            "${destdir}/${mandir}/man1/qi.1"

    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"/
}

